import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
let cube, controls


const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1000 );
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

controls = new OrbitControls( camera, renderer.domElement );
camera.position.set(0,5,10) // 设置摄像机的位置

// 创建一个球体
function createGeometry() {
    // 参数1: 球体半径;
    // 参数2:球体的宽度分段数(水平分了多少份);
    // 参数3:球体的高度分段数,(垂直方向球体分了多少份)
    const geometry = new THREE.SphereGeometry( 2, 64, 64 );
    const material = new THREE.MeshBasicMaterial( { color: 0xEF6820 } );
    const sphere = new THREE.Mesh( geometry, material );
    scene.add( sphere );
}

function createAxes (){ // 总体的
    const axesHelper = new THREE.AxesHelper(20)
    scene.add(axesHelper)
}
function animate() {
	requestAnimationFrame( animate );
	controls.update();
	renderer.render( scene, camera );
}
function resize () {
    window.addEventListener('resize', () => {
        renderer.setSize(window.innerWidth,window.innerHeight)
        camera.aspect = window.innerWidth/window.innerHeight
        camera.updateProjectionMatrix()
    })
}

resize()
createGeometry()
createAxes()
animate()






